<!DOCTYPE html>

<html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>表单</title>

    <style>
        .btn {
            display: inline-block;
            margin: 10px auto;
            border: 1px solid blue;
            border-radius: 5px;
            padding: 5px;
            user-select: none;
        }
    </style>

</head>

<body>

    <form action="http://www.baidu.com/s" method="get">
        <fieldset>
            <legend>百度一下，你就知道</legend>
            <div>
                <input type="text" name="wd">
            </div>
            <div>
                <a class="btn btn-reset">重置</a>
                <a class="btn btn-submit">提交</a>
            </div>
        </fieldset>
    </form>

    <script>
        (function() {
            let form = document.querySelector('form');
            let btn = document.querySelector('.btn-submit');
            let btn_reset = document.querySelector('.btn-reset');
            let fn = function(event) {
                event.preventDefault(); // 阻止事件默认行为
                form.submit(); // 通过表单组件的sumbit函数来提交表单
            }
            let fs = function(event) {
                event.preventDefault(); // 阻止事件默认行为
                form.reset(); // 通过表单组件的reset函数来重置表单
            }
            btn.addEventListener('click', fn, true);
            btn_reset.addEventListener('click', fs, true);
        })();
    </script>

</body>

</html>